package com.qst.rongxiaoserver.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qst.rongxiaoserver.mapper.KnowledgeMapper;
import com.qst.rongxiaoserver.model.KnowledgeModel;
import com.qst.rongxiaoserver.service.IKnowledgeService;
import org.springframework.stereotype.Service;

@Service
public class KnowledgeServiceImpl extends ServiceImpl<KnowledgeMapper, KnowledgeModel> implements IKnowledgeService {

    @Override
    public Page<KnowledgeModel> getKnowledgeList(int pageNum, int pageSize, String title) {
        // 分页查询
        Page<KnowledgeModel> page1 = new Page<>(pageNum, pageSize);

        // 查询条件
        LambdaQueryWrapper<KnowledgeModel> queryWrapper = new LambdaQueryWrapper<>();
        if(title!=null && !title.isEmpty()){
            queryWrapper.like(KnowledgeModel::getTitle,title);   // 模糊查询
        }

        return this.page(page1, queryWrapper);
    }
}